"use strict";
angular.module('app.protocol').controller('DataProtocolCtrl', function($scope,$http,$stateParams,$cookieStore) {
	$scope.protocol_table = 'log_'+$stateParams.port;
	//配置分页基本参数
    $scope.paginationConf = {
        currentPage: 1,
        itemsPerPage: 10,
        pagesLength: 5,
        totalItems: 20,
        perPageOptions: [1, 2, 3, 40, 50],
        onChange: function () {
        }
    };
    $scope.DATA = [];
    $http.get(baseurl+'/table_columns/'+$scope.protocol_table).then(function(res){
        // console.log(res.data);
        if (res.data.ret == 1) {
            for(var i = 0 ; i < res.data.info.length; i++){
                $scope.DATA.push(res.data.info[i].COLUMN_NAME)
            }
            console.log($scope.DATA)
        }
    });
    $scope.get_list = function(){
        var page_obj = {
            page:$scope.paginationConf.currentPage,
            rows:$scope.paginationConf.itemsPerPage
        };
        $http.post(baseurl+'/list/select/'+$scope.protocol_table,page_obj).then(function(res){
            // console.log(res.data);
            $scope.datas = res.data.rows;
            console.log( $scope.datas);
            $scope.paginationConf.totalItems = res.data.records;
        })
    };
    $scope.$watch('paginationConf.currentPage + paginationConf.itemsPerPage', $scope.get_list);


    $scope.arr = [
        [{id:"1",des:"2",info:"3"},{id:"1",des:"2",info:"3"}],
        [{id:"1",des:"2",info:"3"},{id:"1",des:"2",info:"3"}]
    ];
});